package com.ziyueyuwen.xiniao.dao;

import com.ziyueyuwen.xiniao.bean.ZyLessonMessageTask;
import com.ziyueyuwen.xiniao.enums.MessageTypeEnum;
import com.ziyueyuwen.xiniao.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
/**
 * @author wancheng
 */
public interface ZyLessonMessageTaskMapper extends BaseMapper<ZyLessonMessageTask> {
    /**
     * 获取两个时间内的数据
     * @param before
     * @param end
     * @return
     */
    List<ZyLessonMessageTask> getByBetween(@Param("before") Date before, @Param("end") Date end);

    /**
     * 删除
     * @param lessonId
     */
    void deleteByLessonId(Integer lessonId);

    /**
     * 批量保存
     * @param list
     */
    void insertBatch(@Param("list") List<ZyLessonMessageTask> list);

    /**
     * 通过课节id获取 该课节的相关内容
     *
     * @param lessonId
     * @return
     */
    List<ZyLessonMessageTask> getByLessonId(Integer lessonId);

    /**
     * 获取
     * @param courseId
     * @param lessonIndex
     * @param type
     * @return
     */
    List<ZyLessonMessageTask> getByCourseIdAndLessonIndex(@Param("courseId") Integer courseId,
                                                          @Param("lessonIndex") Integer lessonIndex,
                                                          @Param("type") MessageTypeEnum type);

    /**
     * 修改发送时间
     * @param lessonId
     * @param type
     * @param sendTime
     */
    void updateSendTimeByLessonIdAndType(@Param("lessonId") Integer lessonId,
                                         @Param("type") MessageTypeEnum type,
                                         @Param("sendTime") Date sendTime);

    /**
     * 课程 某时间前的任务
     * @param lessonId
     * @param date
     * @return
     */
    List<ZyLessonMessageTask> getTaskByLessonIdAndSendTimeBefore(@Param("lessonId") Integer lessonId,
                                                                 @Param("date")Date date);

    /**
     * 获取学生发送最近发送作业的课节id
     * @param userAccount
     * @return
     */
    Integer getLessonHomeworkRecently(String userAccount);
}